<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Rule class reference &mdash; Dragonfly v0.6.4rc3 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '',
          VERSION:     '0.6.4rc3',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="contents" title="Global table of contents" href="contents.html" />
    <link rel="index" title="Global index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="top" title="Dragonfly v0.6.4rc3 documentation" href="index.html" />
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li><a href="index.html">Dragonfly v0.6.4rc3 documentation</a> &raquo;</li>
      </ul>
    </div>
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  
  <div class="section" id="rule-class-reference">
<span id="refruleclasses"></span><h1>Rule class reference<a class="headerlink" href="#rule-class-reference" title="Permalink to this headline">¶</a></h1>
<p>This section describes the following class:</p>
<blockquote>
<ul class="simple">
<li><a title="dragonfly.grammar.rule.Rule" class="reference internal" href="#dragonfly.grammar.rule.Rule"><tt class="xref docutils literal"><span class="pre">dragonfly.grammar.rule.Rule</span></tt></a> &#8211; the base rule class</li>
</ul>
</blockquote>
<div class="section" id="rule-class">
<h2>Rule class<a class="headerlink" href="#rule-class" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="dragonfly.grammar.rule.Rule">
<!--[dragonfly.grammar.rule.Rule]-->class <tt class="descname">Rule</tt><big>(</big><em>name</em>, <em>element</em>, <em>context=None</em>, <em>imported=False</em>, <em>exported=False</em><big>)</big><a class="headerlink" href="#dragonfly.grammar.rule.Rule" title="Permalink to this definition">¶</a></dt>
<dd><p>Rule class for implementing complete or partial voice-commands.</p>
<p>This rule class represents a voice-command or part of a voice-
command.  It contains a root element, which defines the language 
construct of this rule.</p>
<dl class="docutils">
<dt>Constructor arguments:</dt>
<dd><ul class="first last simple">
<li><em>name</em> (<em>str</em>) &#8211; name of this rule</li>
<li><em>element</em> (<em>Element</em>) &#8211;
root element for this rule</li>
<li><em>context</em> (<em>Context</em>, default: <em>None</em>) &#8211;
context within which to be active.  If <em>None</em>, the rule will
always be active.</li>
<li><em>imported</em> (boolean, default: <em>False</em>) &#8211;
if true, this rule is imported from outside its grammar</li>
<li><em>exported</em> (boolean, default: <em>False</em>) &#8211;
if true, this rule is a complete top-level rule which can be
spoken by the user.  This should be <em>True</em> for voice-commands
that the user can speak.</li>
</ul>
</dd>
</dl>
<p>The <em>self._log</em> logger objects should be used in methods of 
derived classes for logging purposes.  It is a standard logger 
object from the <em>logger</em> module in the Python standard library.</p>
<dl class="attribute">
<dt id="dragonfly.grammar.rule.Rule.name">
<!--[dragonfly.grammar.rule.Rule.name]--><tt class="descname">name</tt><a class="headerlink" href="#dragonfly.grammar.rule.Rule.name" title="Permalink to this definition">¶</a></dt>
<dd>This rule&#8217;s name.  (Read-only)</dd></dl>

<dl class="attribute">
<dt id="dragonfly.grammar.rule.Rule.exported">
<!--[dragonfly.grammar.rule.Rule.exported]--><tt class="descname">exported</tt><a class="headerlink" href="#dragonfly.grammar.rule.Rule.exported" title="Permalink to this definition">¶</a></dt>
<dd>Read-only access to a rule&#8217;s exported state.</dd></dl>

<dl class="attribute">
<dt id="dragonfly.grammar.rule.Rule.imported">
<!--[dragonfly.grammar.rule.Rule.imported]--><tt class="descname">imported</tt><a class="headerlink" href="#dragonfly.grammar.rule.Rule.imported" title="Permalink to this definition">¶</a></dt>
<dd>This rule&#8217;s imported status.  (Read-only)</dd></dl>

<dl class="attribute">
<dt id="dragonfly.grammar.rule.Rule.grammar">
<!--[dragonfly.grammar.rule.Rule.grammar]--><tt class="descname">grammar</tt><a class="headerlink" href="#dragonfly.grammar.rule.Rule.grammar" title="Permalink to this definition">¶</a></dt>
<dd>This rule&#8217;s grammar object.  (Set once)</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.rule.Rule.process_begin">
<!--[dragonfly.grammar.rule.Rule.process_begin]--><tt class="descname">process_begin</tt><big>(</big><em>executable</em>, <em>title</em>, <em>handle</em><big>)</big><a class="headerlink" href="#dragonfly.grammar.rule.Rule.process_begin" title="Permalink to this definition">¶</a></dt>
<dd><p>Start of phrase callback.</p>
<p>This method is called when the speech recognition 
engine detects that the user has begun to speak a 
phrase.  It is called by the rule&#8217;s containing grammar
if the grammar and this rule are active.</p>
<p>The default implementation of this method checks
whether this rule&#8217;s context matches, and if it does
this method calls
<a title="dragonfly.grammar.rule.Rule._process_begin" class="reference internal" href="#dragonfly.grammar.rule.Rule._process_begin"><tt class="xref docutils literal"><span class="pre">dragonfly.grammar.rule.Rule._process_begin()</span></tt></a>.</p>
<dl class="docutils">
<dt>Arguments:</dt>
<dd><ul class="first last simple">
<li><em>executable</em> &#8211; the full path to the module whose 
window is currently in the foreground</li>
<li><em>title</em> &#8211; window title of the foreground window</li>
<li><em>handle</em> &#8211; window handle to the foreground window</li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.rule.Rule._process_begin">
<!--[dragonfly.grammar.rule.Rule._process_begin]--><tt class="descname">_process_begin</tt><big>(</big><big>)</big><a class="headerlink" href="#dragonfly.grammar.rule.Rule._process_begin" title="Permalink to this definition">¶</a></dt>
<dd><p>Start of phrase detection callback.</p>
<p><em>This is generally the method which developers should
override in derived rule classes to give them custom
functionality when the start of a phrase is detected.</em></p>
<p>This method is called when the speech recognition 
engine detects that the user has begun to speak a 
phrase.  It is called by this rule&#8217;s
<a title="dragonfly.grammar.rule.Rule.process_begin" class="reference internal" href="#dragonfly.grammar.rule.Rule.process_begin"><tt class="xref docutils literal"><span class="pre">dragonfly.grammar.rule.Rule.process_begin()</span></tt></a>
after some context checks.</p>
<p>The default implementation of this method does nothing.</p>
</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.rule.Rule.value">
<!--[dragonfly.grammar.rule.Rule.value]--><tt class="descname">value</tt><big>(</big><em>node</em><big>)</big><a class="headerlink" href="#dragonfly.grammar.rule.Rule.value" title="Permalink to this definition">¶</a></dt>
<dd><p>Start of phrase callback.</p>
<p><em>This is generally the method which developers should override 
in derived rule classes to change the default semantic value 
of a recognized rule.</em></p>
<p>This method is called to obtain the semantic value associated 
with a particular recognition.  It could be called from 
another rule&#8217;s <a title="dragonfly.grammar.rule.Rule.value" class="reference internal" href="#dragonfly.grammar.rule.Rule.value"><tt class="xref docutils literal"><span class="pre">dragonfly.grammar.rule.Rule.value()</span></tt></a> if 
that rule references this rule.  If also be called from this 
rule&#8217;s <a title="dragonfly.grammar.rule.Rule.process_recognition" class="reference internal" href="#dragonfly.grammar.rule.Rule.process_recognition"><tt class="xref docutils literal"><span class="pre">dragonfly.grammar.rule.Rule.process_recognition()</span></tt></a>
if that method has been overridden to do so in a derived
class.</p>
<p>The default implementation of this method returns the value of 
this rule&#8217;s root element.</p>
</dd></dl>

<dl class="method">
<dt id="dragonfly.grammar.rule.Rule.process_recognition">
<!--[dragonfly.grammar.rule.Rule.process_recognition]--><tt class="descname">process_recognition</tt><big>(</big><em>node</em><big>)</big><a class="headerlink" href="#dragonfly.grammar.rule.Rule.process_recognition" title="Permalink to this definition">¶</a></dt>
<dd><p>Rule recognition callback.</p>
<p><em>This is generally the method which developers should
override in derived rule classes to give them custom
functionality when a top-level rule is recognized.</em></p>
<p>This method is called when the user has spoken words matching 
this rule&#8217;s contents.  This method is called only once for 
each recognition, and only for the matching top-level rule.</p>
<p>The default implementation of this method does nothing.</p>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3>Table Of Contents</h3>
            <ul>
<li><a class="reference external" href="">Rule class reference</a><ul>
<li><a class="reference external" href="#rule-class">Rule class</a></li>
</ul>
</li>
</ul>

            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/ruleclasses.txt">Show Source</a></li>
            </ul>
            <h3>Quick search</h3>
            <form class="search" action="search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li><a href="index.html">Dragonfly v0.6.4rc3 documentation</a> &raquo;</li>
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2008, Christo Butcher.
      Last updated on Feb 01, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>